﻿using Microsoft.Xna.Framework.Input;


namespace PacMan.Components
{
	/// <summary>
	/// Input struct
	/// </summary>
	public struct Input
	{
		public bool up, down, left, right, p, space;

		public Input(bool val)
		{
			up = down = left = right = p = space = val;
		}
	}

	public static class InputHandler
	{
		private static Input mInput = new Input(false);
		private static bool mIsActive = true;

		public static Input GetInput { get { return mIsActive ? mInput : new Input(false); } }

		public static Input UpdateInput(double i)
		{
			mInput = new Input(false);

			KeyboardState ks = Keyboard.GetState();

			mInput.up = ks.IsKeyDown(Keys.Up);
		
			mInput.down = ks.IsKeyDown(Keys.Down);

			mInput.left = ks.IsKeyDown(Keys.Left);

			mInput.right = ks.IsKeyDown(Keys.Right);

			mInput.p = ks.IsKeyDown(Keys.P);

			mInput.space = ks.IsKeyDown(Keys.Space);

//			mLastKeyboardState = ks;

			return mInput;
		}

	}
}